<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="新增公司" bodyClass="white-bg"/>
<div class="wrapper wrapper-content ibox-content">
	<@f.form id="form-comp-add" class="form-horizontal">
	<@f.hidden name="type" value="0"/>
	<div class="form-group">
		<label class="col-sm-3 control-label "><span style="color: red; ">*</span>上级公司：</label>
		<div class="col-sm-8">
			<@f.treeselect id="parentId" name="parentId" boxTitle="选择上级公司" url="sys/comp/treeData?type=0"
			expandLevel=true value="${comp.id}" labelValue="${comp.name?default('总公司')}" isParentIds=true
			parenIdsValue="${comp.id}${(comp.parentIds == '1')?string('',',${comp.parentIds}')}"
			placeholder="请选择上级公司" required=true/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label"><span style="color: red; ">*</span>公司名称：</label>
		<div class="col-sm-8">
			<@f.input name="name" required=true/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label"><span style="color: red; ">*</span>公司编码：</label>
		<div class="col-sm-8">
			<@f.input name="code" required=true/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label"><span style="color: red; ">*</span>公司全称：</label>
		<div class="col-sm-8">
			<@f.input name="fullName" required=true/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label ">归属地区：</label>
		<div class="col-sm-8">
			<@f.treeselect id="areaId" name="areaIds" boxTitle="请选择管理地区" url="sys/area/treeData"
			checked=true correlationId="parentId" placeholder="请选择管理地区"/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label">显示排序：</label>
		<div class="col-sm-8">
			<input class="form-control" type="text" name="orderNum" required>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "状态"/>：</label>
		<div class="col-sm-8">
			<@f.radio name="status" dictType="sys_normal_disable"/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-3 control-label"><@ctx.i18n text = "备注"/>：</label>
		<div class="col-sm-8">
			<@f.textarea name="remark"/>
		</div>
	</div>
</div>
</@f.form>
<@footer>
<script type="text/javascript">
	var prefix = baseURL + "sys/comp";

	$("#form-comp-add").validate({
		onkeyup: false,
		rules:{
			name:{
				remote: {
					url: prefix + "/checkCompNameUnique",
					type: "POST",
					dataType: "html",
					data: {
						"parentId": function() {
							return $("input[name='parentId']").val();
						},
						"name" : function() {
							return opt.common.trim($("#name").val());
						}
					},
					dataFilter: function(data, type) {
						return opt.validate.unique(data);
					}
				}
			},
			code:{
				/* 数据校验*/
				remote: {
					url: prefix + "/checkCompCodeUnique",
					type: "POST",
					dataType: "html",
					data: {
						"code": function() {
							return opt.common.trim($("#code").val());
						}
					},
					dataFilter: function(data, type) {
						return opt.validate.unique(data);
					}
				}
			},
			orderNum:{
				digits:true
			}
		},
		messages: {
			"name": {
				remote: "已经存在"
			},
			"code":{
				remote: "已经存在"
			}
		},
		focusCleanup: true
	});

	function submitHandler() {
		if (opt.validate.form()) {
			opt.operate.save(prefix + "/add", $('#form-comp-add').serialize());
		}
	}
</script>
</@footer>
</@pageTheme>